/**
 * Copyright (c) 2013-2015, Jieven. All rights reserved.
 *
 * Licensed under the GPL license: http://www.gnu.org/licenses/gpl.txt
 * To use it on other terms please contact us at 1623736450@qq.com
 */
package com.eova.core.front;

import java.util.List;

import com.eova.model.Channel;
import com.eova.model.Content;
import com.eova.model.Displays;
import com.jfinal.aop.ClearInterceptor;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;

/**
 * Eova入口
 *
 * @author Jieven
 * @date 2015-1-6
 */
@ClearInterceptor
public class FrontController extends Controller {

	/**
	 * 首页
	 */
	public void toIndex() {
		List<Displays> list= Displays.dao.queryDisplays();
		setAttr("itemList", list);
		setAttr("currentChannel","0");
		setAttr("channelList", getChannel());
		setAttr("bottomList", getBottomChannel());
		render("/front/content/index.html");
	}

	public void zjth() {
		Content item= Content.dao.queryMinOrder(Integer.valueOf(getPara(0)));
		setAttr("currentChannel", getPara(0));
		setAttr("channelList", getChannel());
		setAttr("bottomList", getBottomChannel());
		setAttr("item", item);
		render("/front/content/zjth.html");
	}
	
	public void hzwhList() {
		Page<Content> page= Content.dao.paginate(Integer.parseInt(getPara(1)),6,"select *", "from  eova_content where channelId ="+getPara(0));
		setAttr("currentChannel", getPara(0));
		setAttr("channelList", getChannel());
		setAttr("bottomList", getBottomChannel());
		setAttr("page", page);
		render("/front/content/hzwhList.html");
	}

	public void hzwhContent() {
		Content item= Content.dao.findById(getPara(1));
		Content itemQ= Content.dao.queryQ(Integer.valueOf(getPara(0)),Integer.valueOf(getPara(1)));
		Content itemH= Content.dao.queryH(Integer.valueOf(getPara(0)),Integer.valueOf(getPara(1)));
		setAttr("item", item);
		setAttr("itemQ", itemQ==null?0:itemQ);
		setAttr("itemH", itemH==null?0:itemH);
		setAttr("currentChannel", getPara(0));
		setAttr("channelList", getChannel());
		setAttr("bottomList", getBottomChannel());
		render("/front/content/hzwhContent.html");
	}
	
	public void cpzsContent() {
		Content item= Content.dao.findById(getPara(1));
		Content itemQ= Content.dao.queryQ(Integer.valueOf(getPara(0)),Integer.valueOf(getPara(1)));
		Content itemH= Content.dao.queryH(Integer.valueOf(getPara(0)),Integer.valueOf(getPara(1)));
		setAttr("item", item);
		setAttr("itemQ", itemQ==null?0:itemQ);
		setAttr("itemH", itemH==null?0:itemH);
		setAttr("currentChannel", getPara(0));
		setAttr("channelList", getChannel());
		setAttr("bottomList", getBottomChannel());
		render("/front/content/cpzsContent.html");
	}
	
	/*
	 * 产品展示列表页
	 */
	public void cpzs1() {
		Page<Content> page= Content.dao.paginate(Integer.parseInt(getPara(1)),9,"select *", "from  eova_content where channelId ="+getPara(0));
		setAttr("page", page);
		setAttr("channelId", getPara(0));
		setAttr("currentChannel", getPara(0));
		setAttr("channelList", getChannel());
		setAttr("bottomList", getBottomChannel());
		render("/front/content/cpzs1.html");
	}
	
	/**
	 * 销售网络
	 */
	public void xswl() {
		Content item= Content.dao.queryMinOrder(Integer.valueOf(getPara(0)));
		setAttr("currentChannel", getPara(0));
		setAttr("channelList", getChannel());
		setAttr("bottomList", getBottomChannel());
		setAttr("item", item);
		render("/front/content/xswl.html");
	}
	
	/**
	 * 欢迎加盟
	 */
	public void hyjm() {
		Content item= Content.dao.queryMinOrder(Integer.valueOf(getPara(0)));
		setAttr("currentChannel", getPara(0));
		setAttr("channelList", getChannel());
		setAttr("bottomList", getBottomChannel());
		setAttr("item", item);
		render("/front/content/hyjm.html");
	}
	
	/**
	 * 联系我们
	 */
	public void lxwm() {
		Content item= Content.dao.queryMinOrder(Integer.valueOf(getPara(0)));
		setAttr("currentChannel", getPara(0));
		setAttr("channelList", getChannel());
		setAttr("bottomList", getBottomChannel());
		setAttr("item", item);
		render("/front/content/lxwm.html");
	}
	
	public List<Channel> getChannel() {
		return Channel.dao.queryHeadChannelLimit6();
	}
	
	public List<Channel> getBottomChannel() {
		return Channel.dao.queryBottomChannelLimit5();
	}
	
	public void index() {
		
		toIndex();
	}

	

}